<template>
    <div>
        <h1>科室新增</h1>
        <table class="table">
            <tr>
                <td>科室名称</td>
                <td><input type="text" v-model="data.rname"></td>
            </tr>
            <tr>
                <td>科室人数</td>
                <td><input type="text" v-model="data.rnum"></td>
            </tr>
            <tr>
                <td>科室描述</td>
                <td><textarea v-model="data.rms"></textarea></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="button" value="新增" @click="add"></td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios'
import {ref,onMounted} from 'vue'
import {useRouter,useRoute} from 'vue-router'
import moment from 'moment'
const router=useRouter();
const route=useRoute();
const data=ref({
    "rid": 0,
  "rname": "",
  "rnum": 0,
  "rms": "",
  "rtime": "2025-05-19T03:20:28.657Z",
  "isDelete": true
})
const add=()=>{
    axios.post("/api/RoomKs/AddRoomKs",data.value).then(res=>{
        if(res.data==-1){
            alert("科室名称不能重复")
            return
        }
        if(res.data>0){
            alert("新增成功")
            router.push({path:"/rshow"})
        }else{
            alert("新增失败")
            return
        }
    })
}
</script>

<style scoped>

</style>